/*
 +-----------------------------------------------------------------------------------------------+
 | Project : UKAPI
 +-----------------------------------------------------------------------------------------------+
 | Project Description : Universal & Kernel API
 +-----------------------------------------------------------------------------------------------+
 | File Description :
 |   File System
 |                                                 
 +-----------------------------------------------------------------------------------------------+
 | Licence : MIT Licence
 +-----------------------------------------------------------------------------------------------+
 | Copyright (c) 2006 Olivier Vanhoucke
 | 
 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software 
 | and associated documentation files (the "Software"), to deal in the Software without 
 | restriction, including without limitation the rights to use, copy, modify, merge, publish, 
 | distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 
 | Software is furnished to do so, subject to the following conditions:
 | 
 | The above copyright notice and this permission notice shall be included in all copies or 
 | substantial portions of the Software.
 | 
 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
 | BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 +-----------------------------------------------------------------------------------------------+
*/

#ifndef __UKAPI_KERNEL_FILE_SYSTEM__
#define __UKAPI_KERNEL_FILE_SYSTEM__

#include <ukapi.h>
#include <dlist.h>
#include <buffer.h>

typedef struct 
{
	dlist_t root_tree; // override with a tree_t API ?
	size_t	maxsize; // ?
} file_system_t, * pfile_system_t;

typedef enum
{
	file_system_node_type_directory_e,
	file_system_node_type_file_e,
} file_system_node_type_t;

typedef struct 
{
	char_ascii_t	name[255];
	// rights
	// how to ask for primitives calls ?
	dlist_t		tree;
} fs_directory_t, * pfs_directory_t; // see directory.h

typedef struct 
{
	char_ascii_t	name[255];
	// rights
	// share
	buffer_t	buffer;
} fs_file_t, * pfs_file_t; // see file.h

typedef struct 
{
	union
	{
		fs_directory_t	fs_directory;
		fs_file_t		fs_file;
	} content;
	file_system_node_type_t		type;
} file_system_node_t, * pfile_system_node_t;

#ifdef __cplusplus
	extern "C" {
#endif /* __cplusplus */

result_t file_system_init( pfile_system_t pfs );
result_t file_system_insert_node( pfile_system_t pfs, pfile_system_node_t pnode );
result_t file_system_remove_node( pfile_system_t pfs, pfile_system_node_t pnode );
result_t file_system_find_node( pfile_system_t pfs, string_ascii_t path );
result_t file_system_destroy( pfile_system_t pfs );

result_t file_system_mount( pfile_system_t pfs ); //merge tree ?
result_t file_system_unmount( pfile_system_t pfs );

#ifdef __cplusplus
	}
#endif /* __cplusplus */

#endif /* __UKAPI_KERNEL_FILE_SYSTEM__ */
